package com.battery.controller;

import com.battery.pojo.User;
import com.battery.service.UserService;
import com.battery.util.result.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@Api(tags = "用户管理相关接口")
@RequestMapping("/user")
public class UserController {
    @Autowired
    private UserService userService;

    @PostMapping("/addUser")
    @ApiOperation("添加用户")
    public Result addUser(User user) {
        return userService.addUser(user);
    }

    @DeleteMapping("/dropUser/{user_id}")
    @ApiOperation("根据id删除用户信息")
    public Result dropUser(@PathVariable("user_id") int user_id) {
        return userService.dropUser(user_id);
    }

    @PutMapping("/modifyUser")
    @ApiOperation("修改用户信息")
    public Result modifyUser(User user) {
        return userService.modifyUser(user);
    }

    @GetMapping("/queryUser/{user_id}")
    @ApiOperation("根据id查询用户信息")
    public Result queryUser(@PathVariable("user_id") int user_id) {
        return userService.queryUser(user_id);
    }
}